<template>
    <div class="chatPage">
        <template v-if="userPackageInfo.level===0">
            <div class="flex_center align_center flex_column" style="width: 100%; height: 100%; background: #fff; padding-top: 15px;">
                <img src="../../assets//lock.png" style="width: 150px; height: 150px;">
                <p style="padding-top: 15px; font-weight: 600;">升级套餐，即可解锁此功能体验</p>
                <div class="text_center margin20" style="width: 180px; height: 36px; background: #0147fd; border-radius: 4px; color: #fff; line-height: 36px; cursor: pointer;" @click="serviceDialog=true">联系客服，升级套餐</div>
            </div>
            <serviceVue :dialogTableVisible10="serviceDialog" @beforeClose="serviceDialog=false"></serviceVue>
        </template>
        <template v-else>
            <div class="chatPageInner flex">
                <listVue ref="listChild" @opration="opration"></listVue>
                <div class="chatVue flex_column relative">
                    <chatBodyVue ref="chatChild"></chatBodyVue>
                </div>
                <remarkVue v-if="JSON.stringify(currentChat)!='{}' && currentChat.type===0"  @opration="opration"></remarkVue>
            </div>
        </template>
    </div>
</template>

<script>
import { mapState } from "vuex"
import listVue from './components/list.vue'
import chatBodyVue from "./components/chatBody.vue"
import remarkVue from "./components/remark.vue"
import serviceVue from '@/components/service.vue';
export default {
    components: {
        listVue,
        chatBodyVue,
        remarkVue,
        serviceVue
    },
    data(){
        return {
            selectList: [],
            serviceDialog: false
        }
    },

    created(){
        this.$store.dispatch("getUserPackageInfo")
    },

    mounted(){
        setTimeout(() => {
            let obj = {
                userWechatPrimaryId: this.currentWeChat.currentWeChatId,
                userWechatName: this.currentWeChat.currentUserWechatName,
                automaticResponse: "",
                categoryId: "",
                tag: "",
                content: ""
            }
            console.log("kkkkkkkkkkkkkkkkk", obj)
            this.$store.dispatch("getChatting", obj)
            if(JSON.stringify(this.currentChat)!="{}") this.$refs.chatChild.getHistory()
        }, 1000);
       
    },

    computed: {
        ...mapState({
            currentChat: state=> state.currentChat,
            user: state=> state.user,
            currentWeChat: state=> state.currentWeChat,
            weChatList: state=> state.weChatList,
            userPackageInfo: state=> state.userPackageInfo
        })
    },

    methods: {
        opration(data){
            console.log(data)
            if(data===1) this.$refs.chatChild.getHistory(1)
            if(data===2) this.$refs.listChild.getList()
        },  
    }
}
</script>


<style lang="less" scoped>
:deep(.el-icon-search:before) {
    color: #AAA !important;
}
:deep(.el-switch__core) {
    width: 28px !important;
    height: 15px;
}
:deep(.el-switch__core:after) {
    width: 11px;
    height: 11px;
}
:deep(.el-switch.is-checked .el-switch__core::after) {
    margin-left: -12px;
}

:deep(.el-input.is-disabled .el-input__inner) {
    color: #606266;
    background-color: #FAFAFA;
}
:deep(.el-tag--info) {
    margin-right: 10px;
    margin-bottom: 10px;
    cursor: pointer;
}
:deep(.el-icon-circle-close) {
    font-size: 18px !important;
    color: #409EFF !important;
}
.dialogVue {
    width: 100%;
    .headerVue {
        width: 100%;
        height: 60px;
        padding: 20px 20px 0 20px;
        .tabVue {
            display: flex;
            .tab {
                width: 120px;
                height: 40px;
                background: #f5f5f5;
                border-radius: 5px;
                line-height: 40px;
                text-align: center;
                color: #333;
                margin-right: 10px;
                cursor: pointer;
            }
            .active {
                background: #0147fd;
                color: #fff;
            }
        }
    }
    .bodyVue {
        width: 100%;
        height: calc(80vh - 174px);
        padding: 0 20px;
        overflow: scroll;
        .bodyInner {
            width: 100%;
            .ver {
                width: 246px;
                height: 50px;
                border: 1px solid #f5f5f5;
                margin-bottom: 10px;
                margin-right: 10px;
                padding: 0 7px;
                border-radius: 5px;
                cursor: pointer;
                span {
                    font-size: 12px;
                    padding: 0 10px;
                }
            }
            .ver:nth-child(3n) {
                margin-right: 0;
            }
            .active {
                border: #0147fd 1px solid;
                background: rgba(1,71,253, 0.1);
            }
        }  
    }
    .bodyVue::-webkit-scrollbar {
        width: 0;
        height: 0;
    }
    .paginationVue {
        width: 100%;
        height: 60px;
        background: #fff;
        padding: 0 20px 0 10px;
        .btn {
            width: 120px;
            height: 40px;
            text-align: center;
            line-height: 40px;
            background: #0147fd;
            border-radius: 5px;
            color: #fff;
            cursor: pointer;
            margin-left: 10px;
        }
        .btn1 {
            width: 100px;
            height: 40px;
            text-align: center;
            line-height: 40px;
            background: #999;
            border-radius: 5px;
            color: #fff;
            cursor: pointer;
            margin-left: 10px;
        }
        .active {
            background: #0147fd;
        }
    }
}

.chatPage {
    width: 100%;
    height: 100%;
    background: #f5f5f5;
    .top {
        width: 100%;
        height: 60px;
        border-bottom: 1px solid #f5f5f5;
        background: #fff;
        padding: 0 15px;
        .charge {
            width: 60px;
            height: 36px;
            border-radius: 4px;
            line-height: 36px;
            text-align: center;
            background: #0147fd;
            color: #fff;
            cursor: pointer;
        }
    }
    .chatPageInner {
        width: 100%;
        height: 100%;
    }
    .friendVue {
        width: 360px;
        height: 100%;
        background: #fff;
        padding: 15px;
        border-right: 1px solid #f5f5f5;
        .manageBtn {
            background: #f5f5f5;
            border-radius: 4px;
            width: 100%;
            height: 40px;
            line-height: 40px;
            text-align: center;
            color: #666;
            cursor: pointer;
            font-size: 12px;
            font-weight: 500;
            span {
                font-size: 12px;
                font-weight: 500;
                color: #666;
            }
        }
        .selectVue {
            width: 100%;
            .btn {
                width: 48%;
                height: 40px;
                line-height: 40px;
                text-align: center;
                border: 1px solid #DCDFE6;
                border-radius: 5px;
                color: #333;
                cursor: pointer;
            }
        }   
        .tabVue {
            width: 100%;
            height: 40px;
            margin-top: 10px;
            .tab {
                width: 33.3333333%;
                height: 40px;
                line-height: 40px;
                text-align: center;
                background: #f5f5f5;
                cursor: pointer;
                font-size: 13px;
                position: relative;
            }
            .tab:nth-child(1) {
                border-radius: 5px 0 0 5px ;
            }
            .tab:nth-child(3) {
                border-radius: 0 5px 5px 0;
            }
            .active {
                background: #0147fd;
                color: #fff;
            }
            .textActive {
                color: #0147fd;
            }
        } 
        .friendList {
            width: 100%;
            margin-top: 10px;
            height: calc(100% - 213px);
            overflow: scroll;
            .emptyVue {
                width: 100%;
                height: 100%;
                .emptyIcon {
                    width: 280px;
                    height: 155px;
                    margin-bottom: 15px;
                }
                span {
                    color: #AAA;
                }
            }
            .item {
                width: 100%;
                height: 60px;
                border-bottom: 1px solid #f5f5f5;
                cursor: pointer;
                padding: 0 8px;
                .name {
                    width: 100%;
                    color: #111;
                    font-weight: 600;
                    font-size: 13px;
                }
                .message, .time {
                    color: #AAA;
                    font-size: 13px;
                }
                .state {
                    width: 26px;
                    height: 15px;
                    background: #AAA;
                    border-radius: 10px;
                    position: relative;
                    margin-left: 20px;
                    cursor: pointer;
                    .dot {
                        width: 11px;
                        height: 11px;
                        background: #fff;
                        border-radius: 50%;
                        position: absolute;
                    }
                    .dot_left {
                        left: 2px;
                        top: 2px;
                    }
                    .dot_right {
                        right: 2px;
                        top: 2px;
                    }
                }
                .active {
                    background: #0147fd;
                }
            }
            .item:hover {
                background: #ececec;
            }
            .active {
                background: #ececec;
            }
        }    
        .friendList::-webkit-scrollbar {
            width: 0;
            height: 0;
            background-color: transparent;
        }    
    } 

    .chatVue {
        flex: 1;
        height: 100%;
        background:#fff;
        border-right: 1px solid #f5f5f5;
        .title {
            width: 100%;
            height: 40px;
            line-height: 40px;
            text-align: center;
            font-weight: 600;
        }
        .content {
            width: 100%;
            flex: 1;
            overflow-y: scroll;
            .li {
                width: 100%;
                padding: 10px 0;
                .location1 {
                    display: flex;
                    justify-content: end;
                    .left {
                        padding-right: 10px;
                        display: flex;
                        justify-content: end;
                        align-items: end;
                        flex-direction: column;
                        max-width: 60%;
                        .name {
                            color: #999;
                            font-weight: 600;
                            font-size: 14px;
                        }
                        .messagevue {
                            background: #0147fd;
                            border-radius: 5px;
                            color: #fff;
                            line-height: 1.4;
                            padding: 10px;
                            margin-top: 10px;
                            word-break: break-all;
                            white-space: wrap;
                        }
                    }
                }
                .location0 {
                    .right {
                        padding-left: 10px;
                        max-width: 60%;
                        .name {
                            color: #999;
                            font-size: 14px;
                            font-weight: 600;
                        }
                        .messagevue {
                            background: #f5f5f5;
                            border-radius: 5px;
                            color: #333;
                            line-height: 1.4;
                            padding: 10px;
                            margin-top: 10px;
                            word-break: break-all;
                            white-space: wrap;
                        }
                    }
                }   
                
            }
        }
        .sendVue {
            width: 100%;
            height: 150px;
            border: 1px solid #f5f5f5;
            border-radius: 8px;
            margin-top: 10px;
            .botVue {
                width: 100%;
                height: 60px;
                padding: 0 15px;
                .fileBtn {
                    width: 100%;
                    height: 100%;
                    position: absolute;
                    left: 0;
                    top: 0;
                    opacity: 0;
                    cursor: pointer;
                    z-index: 98;
                    border: none;
                    outline: none;
                }
            }
            textarea {
                width: 100%;
                height: 90px;
                display: block;
                box-sizing: border-box;
                resize: none;
                border-radius: 4px;
                font-family: PingFangSC, PingFang SC;
                padding: 10px;
                font-size: 14px;
            }
            ::-webkit-input-placeholder { /* WebKit browsers */
                color: #AAA;
                font-size: 14px;
                font-family: PingFangSC, PingFang SC;
            }
            :-moz-placeholder { /* Mozilla Firefox 4 to 18 */
                color: #AAA;
                font-size: 14px;
                font-family: PingFangSC, PingFang SC;
            }
            ::-moz-placeholder { /* Mozilla Firefox 19+ */
                color: #AAA;
                font-size: 14px;
                font-family: PingFangSC, PingFang SC;
            }
            :-ms-input-placeholder { /* Internet Explorer 10+ */
                color: #AAA;
                font-size: 14px;
                font-family: PingFangSC, PingFang SC;
            }
        }
    }

    .rightVue {
        width: 360px;
        height: 100%;
        background: #fff;
        padding: 20px;
        overflow: scroll;
        .label {
            font-size: 15px;
            font-weight: 600;
            color: #111;
        }
        .btn {
            width: 100%;
            height: 42px;
            text-align: center;
            line-height: 42px;
            background: #0147fd;
            border-radius: 5px;
            color: #fff;
            margin-top: 30px;
            cursor: pointer;
        }
        .inpVue {
            margin-top: 20px;
            .key {
                color: #333;
                font-size: 13px;
            }
            .inner {
                width: 100%;
                height: 80px;
                border-radius: 4px;
                background: #FAFAFA;
                margin-top: 8px;
                padding: 10px;
                border: #E4E7ED 1px solid;
                overflow: scroll
            }
            .inner::-webkit-scrollbar {
                width: 0;
                height: 0;
            }
            textarea {
                width: 100%;
                height: 80px;
                border: 1px solid #DCDFE6;
                border-radius: 4px;
                display: block;
                resize: none;
                padding: 5px;
                line-height: 1.4;
                color: #606266;
                font-size: 13px;
                font-family: PingFangSC, PingFang SC;
                margin-top: 8px;
            }

            ::-webkit-input-placeholder { /* WebKit browsers */
                color: #AAA;
                font-size: 13px;
                font-family: PingFangSC, PingFang SC;
            }
            :-moz-placeholder { /* Mozilla Firefox 4 to 18 */
                color: #AAA;
                font-size: 13px;
                font-family: PingFangSC, PingFang SC;
            }
            ::-moz-placeholder { /* Mozilla Firefox 19+ */
                color: #AAA;
                font-size: 13px;
                font-family: PingFangSC, PingFang SC;
            }
            :-ms-input-placeholder { /* Internet Explorer 10+ */
                color: #AAA;
                font-size: 13px;
                font-family: PingFangSC, PingFang SC;
            }
            textarea::-webkit-scrollbar {
                width: 0;
                height: 0;
            }
        }
    }

    .rightVue::-webkit-scrollbar {
        width: 0;
        height: 0;
    }
}
</style>